
import 'dart:io';
import 'dart:typed_data';

import 'package:path_provider/path_provider.dart';

Future<String> writeByteToImageFile(ByteData byteData) async {
  // Directory dir = Platform.isAndroid
  //     ? await getExternalStorageDirectory()
  //     : await getApplicationDocumentsDirectory();

  Directory dir = await getApplicationDocumentsDirectory();
  File imageFile = File(
      "${dir.path}/flutter/${DateTime.now().millisecondsSinceEpoch}.png");
  imageFile.createSync(recursive: true);
  imageFile.writeAsBytesSync(byteData.buffer.asUint8List(0));
  return imageFile.path;
}
